package com.mywork.service;

import com.spring.*;

@Component("userService")
//@Scope("prototype")
//如果把Scope注解去掉 Spring默认为单例的
public class UserService implements BeanNameAware , InitializingBean,UserInterface {
    @Autowired
    private OrderService orderService;

    private String beanName;

    private User defaultUser;
    @Override
    public void setBeanName(String beanName) {
        this.beanName = beanName;
        System.out.println("这个bean的beanName属性值被设置为了"+beanName);
    }
    public String  getBeanName(String beanName) {
        System.out.println("这个bean的beanName属性值为"+beanName);
        return this.beanName;
    }
    @Override
    public void afterPropertiesSet() {
//        Autowired属性注入完之后可以在初始化Bean中执行一些操作
        defaultUser = new User();
        System.out.println("初始化操作，实例化User对象"+defaultUser.toString());
    }
    @Override
    public void test(){

        System.out.println(orderService);
    }
}
